/*
Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
getMin() -- Retrieve the minimum element in the stack.

*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include <unordered_set>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/
typedef __int32 uint32_t;


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}


class MinStack {
private:
	stack<int> stack1;

	stack<int> minStack;
public:
	void push(int x) {
		stack1.push(x);
		if (minStack.empty() || ((!minStack.empty()) && (x <= minStack.top())))
			minStack.push(x);
	}

	void pop() {
		if (!stack1.empty())
		{
			if (stack1.top() == minStack.top())
			{
				minStack.pop();
			}
			stack1.pop();

		}
	}

	int top() {
		if (!stack1.empty())
		{

			return stack1.top();

		}
	}

	int getMin() {
		if (!minStack.empty())
		{

			return minStack.top();

		}

	}
};



class Solution2 {
public:
	double Factorial(int n)
	{
		if (n == 0 || n == 1)
		{
			return 1;
		}
		else
		{
			return n * Factorial(n - 1);
		}
	}
	int trailingZeroes(int n) {

		cout << "start" << endl;
		if (n == 0)
			return 0;

		double factNum = 0;
		factNum = Factorial(n);


		cout << "endFact" << factNum << endl;

		double temp;
		int result = 0;


		while (factNum == 0)
		{

			if (fmod(factNum, 10) == 0)
			{
				factNum /= 10;
				result++;
			}
			else
			{
				factNum /= 10;

			}
		}
		return result;
	}
};



int main(int argc, char* argv[])
{


	int a = 0;

	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;
		a = atoi(argv[i]);
	}


	double f = 19;



	Solution s;
	//stackTree.push(p->left);
	//stackTree.push(p->right);

	cout << s.Factorial(a) << endl;
	cout << s.trailingZeroes(10) << endl;
	system("pause");
	return 0;
}